<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="官网https:&#x2F;&#x2F;flywaydb.org&#x2F; 简介Flyway是独立于数据库的应用、管理并跟踪数据库变更的数据库版本管理工具。用通俗的话讲，Flyway可以像Git管理不同人的代码那样，管理不同人的sql脚本，从而做到数据库同步。 在Maven中集成并使用Maven中引入Flyway插件与MySQL整合12345678910111213141516171819202122232425262728">
<meta property="og:type" content="article">
<meta property="og:title" content="flyway入门使用教程">
<meta property="og:url" content="https:&#x2F;&#x2F;fengzxia.gitee.io&#x2F;posts&#x2F;cd84d80b.html">
<meta property="og:site_name" content="只是学习学习的博客">
<meta property="og:description" content="官网https:&#x2F;&#x2F;flywaydb.org&#x2F; 简介Flyway是独立于数据库的应用、管理并跟踪数据库变更的数据库版本管理工具。用通俗的话讲，Flyway可以像Git管理不同人的代码那样，管理不同人的sql脚本，从而做到数据库同步。 在Maven中集成并使用Maven中引入Flyway插件与MySQL整合12345678910111213141516171819202122232425262728">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gjrr3q.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjdQbj.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjwVeJ.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gj097d.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gj0ZjS.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjB3ad.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjBbz6.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjsZPs.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjyLhd.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;GjcTFe.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gjg3Ox.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gj2uHf.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gj2s29.png">
<meta property="article:published_time" content="2020-04-13T10:22:17.000Z">
<meta property="article:modified_time" content="2020-04-16T12:11:08.502Z">
<meta property="article:author" content="只是学习学习">
<meta property="article:tag" content="数据库版本控制">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https:&#x2F;&#x2F;s1.ax1x.com&#x2F;2020&#x2F;04&#x2F;13&#x2F;Gjrr3q.png">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>flyway入门使用教程</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
      
<link rel="stylesheet" href="/css/rtl.css">

    
    <!-- rss -->
    
    
    
<meta name="generator" content="Hexo 4.1.1"></head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/posts/dd4a526.html"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="/posts/53d4b364.html"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://fengzxia.gitee.io/posts/cd84d80b.html" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://fengzxia.gitee.io/posts/cd84d80b.html&text=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://fengzxia.gitee.io/posts/cd84d80b.html&is_video=false&description=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=flyway入门使用教程&body=Check out this article: https://fengzxia.gitee.io/posts/cd84d80b.html"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://fengzxia.gitee.io/posts/cd84d80b.html&name=flyway入门使用教程&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://fengzxia.gitee.io/posts/cd84d80b.html&t=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#官网"><span class="toc-number">1.</span> <span class="toc-text">官网</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#简介"><span class="toc-number">2.</span> <span class="toc-text">简介</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#在Maven中集成并使用"><span class="toc-number">3.</span> <span class="toc-text">在Maven中集成并使用</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Maven中引入Flyway插件与MySQL整合"><span class="toc-number">3.1.</span> <span class="toc-text">Maven中引入Flyway插件与MySQL整合</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#configuration配置简介"><span class="toc-number">3.1.1.</span> <span class="toc-text">configuration配置简介</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用"><span class="toc-number">3.2.</span> <span class="toc-text">使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-migrate迁移"><span class="toc-number">3.2.1.</span> <span class="toc-text">mvn flyway:migrate迁移</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-clean清除所有表"><span class="toc-number">3.2.2.</span> <span class="toc-text">mvn flyway:clean清除所有表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-info打印迁移信息"><span class="toc-number">3.2.3.</span> <span class="toc-text">mvn flyway:info打印迁移信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-validate校验"><span class="toc-number">3.2.4.</span> <span class="toc-text">mvn flyway:validate校验</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-undo撤销"><span class="toc-number">3.2.5.</span> <span class="toc-text">mvn flyway:undo撤销</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-baseline基准"><span class="toc-number">3.2.6.</span> <span class="toc-text">mvn flyway:baseline基准</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-repair修复"><span class="toc-number">3.2.7.</span> <span class="toc-text">mvn flyway:repair修复</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        flyway入门使用教程
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">只是学习学习的博客</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2020-04-13T10:22:17.000Z" itemprop="datePublished">2020-04-13</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/Java/">Java</a> › <a class="category-link" href="/categories/Java/Flyway/">Flyway</a> › <a class="category-link" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/" rel="tag">数据库版本控制</a>
    </div>


    </div>
  </header>
  

  <div class="content"itemprop ="articleBody">
    <h1 id="官网"><a href="#官网" class="headerlink" title="官网"></a>官网</h1><p><a href="https://flywaydb.org/" target="_blank" rel="noopener">https://flywaydb.org/</a></p>
<h1 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h1><p>Flyway是独立于数据库的应用、管理并跟踪数据库变更的数据库版本管理工具。用通俗的话讲，Flyway可以像Git管理不同人的代码那样，管理不同人的sql脚本，从而做到数据库同步。</p>
<h1 id="在Maven中集成并使用"><a href="#在Maven中集成并使用" class="headerlink" title="在Maven中集成并使用"></a>在Maven中集成并使用</h1><h2 id="Maven中引入Flyway插件与MySQL整合"><a href="#Maven中引入Flyway插件与MySQL整合" class="headerlink" title="Maven中引入Flyway插件与MySQL整合"></a>Maven中引入Flyway插件与MySQL整合</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.flywaydb<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>flyway-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>6.2.4<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">driver</span>&gt;</span>com.mysql.cj.jdbc.Driver<span class="tag">&lt;/<span class="name">driver</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">url</span>&gt;</span>jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai<span class="symbol">&amp;amp;</span>useUnicode=true<span class="symbol">&amp;amp;</span>characterEncoding=utf8<span class="symbol">&amp;amp;</span>useSSL=false<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">user</span>&gt;</span>root<span class="tag">&lt;/<span class="name">user</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">password</span>&gt;</span>root<span class="tag">&lt;/<span class="name">password</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">locations</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">location</span>&gt;</span>filesystem:src/main/resources/db/migration<span class="tag">&lt;/<span class="name">location</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">locations</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">table</span>&gt;</span>flyway_schema_history<span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">sqlMigrationPrefix</span>&gt;</span>V<span class="tag">&lt;/<span class="name">sqlMigrationPrefix</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">undoSqlMigrationPrefix</span>&gt;</span>U<span class="tag">&lt;/<span class="name">undoSqlMigrationPrefix</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">repeatableSqlMigrationPrefix</span>&gt;</span>R<span class="tag">&lt;/<span class="name">repeatableSqlMigrationPrefix</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">sqlMigrationSeparator</span>&gt;</span>__<span class="tag">&lt;/<span class="name">sqlMigrationSeparator</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">sqlMigrationSuffixes</span>&gt;</span>.sql<span class="tag">&lt;/<span class="name">sqlMigrationSuffixes</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">encoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">encoding</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>mysql<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mysql-connector-java<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>8.0.19<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>


<h3 id="configuration配置简介"><a href="#configuration配置简介" class="headerlink" title="configuration配置简介"></a><code>configuration</code>配置简介</h3><table>
<thead>
<tr>
<th align="center">参数</th>
<th align="center">是否必须</th>
<th align="center">默认值</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">driver</td>
<td align="center">否</td>
<td align="center">会根据数据库连接自动判断</td>
<td align="center">用于连接数据库的jdbc驱动</td>
</tr>
<tr>
<td align="center">url</td>
<td align="center">是</td>
<td align="center">–</td>
<td align="center">连接数据库的链接，对特殊符号需要进行转义。例如：<code>&amp;</code>需要转为<code>&amp;amp;</code></td>
</tr>
<tr>
<td align="center">user</td>
<td align="center">否</td>
<td align="center">–</td>
<td align="center">数据库账号名</td>
</tr>
<tr>
<td align="center">password</td>
<td align="center">否</td>
<td align="center">–</td>
<td align="center">数据库账号密码</td>
</tr>
<tr>
<td align="center">locations</td>
<td align="center">否</td>
<td align="center">filesystem:src/main/resources/db/migration</td>
<td align="center">指定数据库迁移sql执行脚本路径。有两种配置方式:1.通过<code>classpath</code>:指定类路径的包地址。2.通过<code>filesystem</code>:从项目的跟目录开始填写路径</td>
</tr>
<tr>
<td align="center">table</td>
<td align="center">否</td>
<td align="center">flyway_schema_history</td>
<td align="center">记录flyway框架执行的历史记录名称，库中没有会自动创建</td>
</tr>
<tr>
<td align="center">sqlMigrationPrefix</td>
<td align="center">否</td>
<td align="center">V</td>
<td align="center">版本化SQL迁移文件名前缀，一般sql脚本的命名规范为<code>前缀+版本号+分割符+描述+后缀</code>。例如<code>V1.1__Create_new_table.sql</code></td>
</tr>
<tr>
<td align="center">undoSqlMigrationPrefix</td>
<td align="center">否</td>
<td align="center">U</td>
<td align="center">撤销SQL迁移的脚本文件名前缀。撤销与该脚本具有相同版本号的SQL迁移文件造成的影响。文件命名结构：<code>前缀+版本号+分割符+描述+后缀</code>。例如:<code>U1.1__Undo.sql</code>。<strong>此配置仅限于商业版可用，社区版不可用</strong></td>
</tr>
<tr>
<td align="center">repeatableSqlMigrationPrefix</td>
<td align="center">否</td>
<td align="center">R</td>
<td align="center">可重复执行的SQL迁移脚本，命名规范:<code>前缀+分割符+描述+后缀</code>。例如：<code>R__Repea_run.sql</code></td>
</tr>
<tr>
<td align="center">sqlMigrationSeparator</td>
<td align="center">否</td>
<td align="center">__</td>
<td align="center">SQL迁移的文件名分隔符。<strong>注意是双下划线而不是一个</strong></td>
</tr>
<tr>
<td align="center">sqlMigrationSuffixes</td>
<td align="center">否</td>
<td align="center">.sql</td>
<td align="center">SQL迁移文件后缀。文件命名结构:<code>V1.1__Add_data.sql</code>。<br />可以指定多个后缀。例如：<code>.sql,.pkg,.pkd</code>。方便与其他工具兼容</td>
</tr>
<tr>
<td align="center">encoding</td>
<td align="center">否</td>
<td align="center">UTF-8</td>
<td align="center">指定SQL脚本编码格式</td>
</tr>
</tbody></table>
<ul>
<li>更多配置可参考<a href="https://flywaydb.org/documentation/maven/migrate#configuration" target="_blank" rel="noopener">官网</a></li>
</ul>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><h3 id="mvn-flyway-migrate迁移"><a href="#mvn-flyway-migrate迁移" class="headerlink" title="mvn flyway:migrate迁移"></a><code>mvn flyway:migrate</code>迁移</h3><p><img src="https://s1.ax1x.com/2020/04/13/Gjrr3q.png" alt="Gjrr3q.png"></p>
<p>将架构迁移到最新版本。 如果<code>flyway_schema_history</code>不存在，它将自动创建架构历史记录表。</p>
<blockquote>
<p> 迁移是Flyway工作流程的核心。它将扫描文件列表或类路径以获取可用的迁移。它将它们与已应用于数据库的迁移进行比较。如果发现任何差异，它将迁移数据库以缩小差距。</p>
<p> 迁移最好在应用程序启动时执行，以避免数据库和代码期望之间的任何不兼容性。</p>
<p> 执行迁移是幂等的，并且可以安全地完成迁移，而不管架构的当前版本如何。</p>
<ul>
<li><p>示例1：我们具有9版之前的迁移功能，并且数据库的版本为5版。<br>迁移将依次应用迁移6、7、8和9。</p>
</li>
<li><p>示例2：我们提供了版本9之前的可用迁移，并且数据库的版本为9。<br>迁移不执行任何操作。</p>
<p>以上内容原自<a href="https://flywaydb.org/documentation/command/migrate#behavior" target="_blank" rel="noopener">官网</a>，使用Google翻译进行的机翻</p>
</li>
</ul>
</blockquote>
<ol>
<li><p>在<code>src/main/resources/db/migration</code>目录下创建第一个sql迁移脚本<code>V1.0__Create_user_table.sql</code></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">DROP</span> <span class="keyword">TABLE</span> <span class="keyword">IF</span> <span class="keyword">EXISTS</span> <span class="string">`user`</span>;</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> <span class="string">`user`</span>  (</span><br><span class="line"> <span class="string">`id`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span> AUTO_INCREMENT,</span><br><span class="line"> <span class="string">`create_time`</span> datetime(<span class="number">0</span>) <span class="literal">NULL</span> <span class="keyword">DEFAULT</span> <span class="keyword">CURRENT_TIMESTAMP</span>,</span><br><span class="line"> <span class="string">`update_time`</span> datetime(<span class="number">0</span>) <span class="literal">NULL</span> <span class="keyword">DEFAULT</span> <span class="keyword">CURRENT_TIMESTAMP</span>,</span><br><span class="line"> <span class="string">`valid`</span> <span class="built_in">tinyint</span>(<span class="number">2</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span> <span class="keyword">DEFAULT</span> <span class="number">0</span> <span class="keyword">COMMENT</span> <span class="string">'是否有效 0.有效 1.无效'</span>,</span><br><span class="line"> <span class="string">`delete_time`</span> datetime(<span class="number">0</span>) <span class="literal">NULL</span> <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line"> <span class="string">`name`</span> <span class="built_in">varchar</span>(<span class="number">255</span>) <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> utf8mb4 <span class="keyword">COLLATE</span> utf8mb4_unicode_ci <span class="keyword">NOT</span> <span class="literal">NULL</span> <span class="keyword">COMMENT</span> <span class="string">'账号名称'</span>,</span><br><span class="line"> <span class="string">`password`</span> <span class="built_in">varchar</span>(<span class="number">255</span>) <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> utf8mb4 <span class="keyword">COLLATE</span> utf8mb4_unicode_ci <span class="keyword">NOT</span> <span class="literal">NULL</span> <span class="keyword">COMMENT</span> <span class="string">'加密后密码'</span>,</span><br><span class="line"> <span class="string">`salt`</span> <span class="built_in">varchar</span>(<span class="number">255</span>) <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> utf8mb4 <span class="keyword">COLLATE</span> utf8mb4_unicode_ci <span class="keyword">NOT</span> <span class="literal">NULL</span> <span class="keyword">COMMENT</span> <span class="string">'密码盐值'</span>,</span><br><span class="line"> <span class="string">`admin_role_ids`</span> <span class="built_in">varchar</span>(<span class="number">255</span>) <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> utf8mb4 <span class="keyword">COLLATE</span> utf8mb4_unicode_ci <span class="keyword">NOT</span> <span class="literal">NULL</span> <span class="keyword">COMMENT</span> <span class="string">'角色id（多个使用,号隔开）'</span>,</span><br><span class="line"> PRIMARY <span class="keyword">KEY</span> (<span class="string">`id`</span>) <span class="keyword">USING</span> BTREE</span><br><span class="line">) <span class="keyword">ENGINE</span> = <span class="keyword">InnoDB</span> AUTO_INCREMENT = <span class="number">1</span> <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> = utf8mb4 <span class="keyword">COLLATE</span> = utf8mb4_unicode_ci <span class="keyword">COMMENT</span> = <span class="string">'用户表'</span> ROW_FORMAT = <span class="keyword">Compact</span>;</span><br></pre></td></tr></table></figure>
</li>
<li><p>输入maven命令<code>mvn compile flyway:migrate</code>，可以看到控制台打印，执行成功<br><img src="https://s1.ax1x.com/2020/04/13/GjdQbj.png" alt="GjdQbj.png"></p>
</li>
<li><p>可以查看数据库发现除了<code>user</code>表外还多了一张<code>flyway_schema_history</code>表（图1），这张表中保存了每次执行<code>migration</code>的记录（图2）<br><img src="https://s1.ax1x.com/2020/04/13/GjwVeJ.png" alt="图1"></p>
</li>
</ol>
<p>   <img src="https://s1.ax1x.com/2020/04/13/Gj097d.png" alt="图2"></p>
<ol start="4">
<li><p>当再次执行<code>mvn compile flyway:migrate</code>命令时，控制台会打印，目前数据库处于最新版本，无需进行迁移<br><img src="https://s1.ax1x.com/2020/04/13/Gj0ZjS.png" alt="Gj0ZjS.png"></p>
</li>
<li><p>可以再创建一个sql脚本<code>V1.1__ADD_data_to_user.sql</code>来向user表中添加数据:</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`test`</span>.<span class="string">`user`</span>(<span class="string">`delete_time`</span>, <span class="string">`name`</span>, <span class="string">`password`</span>, <span class="string">`salt`</span>, <span class="string">`admin_role_ids`</span>) <span class="keyword">VALUES</span></span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>),</span><br><span class="line">(<span class="string">'2020-04-10 11:10:09'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>, <span class="string">'11'</span>)</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="6">
<li>再次执行<code>mvn compile flyway:migrate</code>命令，查看控制台，可以看到flyway自动检测到了版本更新，并执行了添加脚本将数据添加到user表中<br><img src="https://s1.ax1x.com/2020/04/13/GjB3ad.png" alt="GjB3ad.png"></li>
</ol>
<p>   <img src="https://s1.ax1x.com/2020/04/13/GjBbz6.png" alt="GjBbz6.png"></p>
<h3 id="mvn-flyway-clean清除所有表"><a href="#mvn-flyway-clean清除所有表" class="headerlink" title="mvn flyway:clean清除所有表"></a><code>mvn flyway:clean</code>清除所有表</h3><p>删除已配置数据库中的所有表。</p>
<p><img src="https://s1.ax1x.com/2020/04/13/GjsZPs.png" alt="GjsZPs.png"></p>
<p>clean对与在开发和测试中有很大的帮助。这样当再执行<code>migrate</code> 迁移命令时会重新创建表，可以避免在测试中出现的一些脏数据影响代码逻辑。</p>
<ul>
<li><strong>在线上环境中慎用</strong></li>
</ul>
<h3 id="mvn-flyway-info打印迁移信息"><a href="#mvn-flyway-info打印迁移信息" class="headerlink" title="mvn flyway:info打印迁移信息"></a><code>mvn flyway:info</code>打印迁移信息</h3><p>打印有关所有迁移的详细信息和状态信息。</p>
<p><img src="https://s1.ax1x.com/2020/04/13/GjyLhd.png" alt="GjyLhd.png"></p>
<h3 id="mvn-flyway-validate校验"><a href="#mvn-flyway-validate校验" class="headerlink" title="mvn flyway:validate校验"></a><code>mvn flyway:validate</code>校验</h3><p>针对已解决的迁移（在文件系统或类路径上）验证已应用的迁移，以检测可能会导致无法准确创建架构的意外更改。</p>
<p>如果验证失败：</p>
<ul>
<li>发现迁移名称，类型或校验和方面的差异</li>
<li>已应用不再在本地解析的版本</li>
<li>已解决尚未应用的版本</li>
</ul>
<p><img src="https://s1.ax1x.com/2020/04/13/GjcTFe.png" alt="GjcTFe.png"></p>
<h3 id="mvn-flyway-undo撤销"><a href="#mvn-flyway-undo撤销" class="headerlink" title="mvn flyway:undo撤销"></a><code>mvn flyway:undo</code>撤销</h3><p>撤消最近应用的版本迁移。</p>
<p><img src="https://s1.ax1x.com/2020/04/13/Gjg3Ox.png" alt="Gjg3Ox.png"></p>
<h3 id="mvn-flyway-baseline基准"><a href="#mvn-flyway-baseline基准" class="headerlink" title="mvn flyway:baseline基准"></a><code>mvn flyway:baseline</code>基准</h3><p>对现有数据库进行基准测试，如果不存在<code>flyway_schema_history</code>文件，则会直接创建，并以当前状态为版本1</p>
<p><img src="https://s1.ax1x.com/2020/04/13/Gj2uHf.png" alt="Gj2uHf.png"></p>
<h3 id="mvn-flyway-repair修复"><a href="#mvn-flyway-repair修复" class="headerlink" title="mvn flyway:repair修复"></a><code>mvn flyway:repair</code>修复</h3><p>修复Flyway模式历史记录表。这将执行以下操作：</p>
<ul>
<li>在没有DDL事务的数据库上删除所有失败的迁移<br>（留下的用户对象仍必须手动清理）</li>
<li>将可用迁移的校验和，描述和类型与可用迁移重新对齐</li>
</ul>
<p><img src="https://s1.ax1x.com/2020/04/13/Gj2s29.png" alt="Gj2s29.png"></p>
<blockquote>
<p>参考 <a href="https://flywaydb.org/documentation/maven/" target="_blank" rel="noopener">官网</a></p>
</blockquote>

<div id="gitalk-container"></div>
<script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script><link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"><script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>

		<script>
		var gitalkConfig = {"clientID":"28a065e3b5afee156f4f","clientSecret":"e18104d6f3219526491fc42c892ff6a26b8f3e74","repo":"blog_comment","owner":"FENG1000","admin":["FENG1000"],"distractionFreeMode":false};
	    gitalkConfig.id = md5(location.pathname);
		var gitalk = new Gitalk(gitalkConfig);
	    gitalk.render("gitalk-container");
	    </script>
    
  <blockquote>
      <p>
          作者: 只是学习学习<br>
          邮箱: fengzxia1000@163.com<br>
          原文地址: <a href="https://fengzxia.gitee.io/posts/cd84d80b.html" target="_blank" rel="noopener">https://fengzxia.gitee.io/posts/cd84d80b.html</a><br>
          版权声明: 商业转载请联系作者获得授权，非商业转载请注明出处。
      </p>
  </blockquote>

  <script>
      function setClipboardText(event){
          // clipboardData 对象是为通过编辑菜单、快捷菜单和快捷键执行的编辑操作所保留的，也就是你复制或者剪切内容
          let clipboardData = event.clipboardData || window.clipboardData;
          // 如果未复制或者未剪切，则return出去
          if (!clipboardData) { return; }
          event.preventDefault();
          // Selection 对象，表示用户选择的文本范围或光标的当前位置。
          //     声明一个变量接收 -- 用户输入的剪切或者复制的文本转化为字符串
          let text = window.getSelection().toString();

          if (text) {
            // 如果文本存在则先取消文本默认事件
            event.preventDefault();
            // 通过调用常clipboardData对象的 setData(format, data) 方法；来设置相关文本
            // format: 一个DOMString 表示要添加到 drag object的拖动数据的类型。
            // data: 一个 DOMString表示要添加到 drag object的数据。
            var copyright = '\n\n'
                            + '\n著作权归作者所有。'
                            + '\n商业转载请联系作者获得授权，非商业转载请注明出处。'
                            + '\n作者: 只是学习学习'
                            + '\n邮箱: fengzxia1000@163.com'
                            + '\n原文地址: https://fengzxia.gitee.io/posts/cd84d80b.html'

            clipboardData.setData('text/plain', text + copyright);

          }
      };
      var contents = document.getElementsByClassName("content");
      // 监听文章内容的copy事件
      contents[0].addEventListener('copy',function(e){
          setClipboardText(e);
      });
  </script>

  </div>
</article>




        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#官网"><span class="toc-number">1.</span> <span class="toc-text">官网</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#简介"><span class="toc-number">2.</span> <span class="toc-text">简介</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#在Maven中集成并使用"><span class="toc-number">3.</span> <span class="toc-text">在Maven中集成并使用</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Maven中引入Flyway插件与MySQL整合"><span class="toc-number">3.1.</span> <span class="toc-text">Maven中引入Flyway插件与MySQL整合</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#configuration配置简介"><span class="toc-number">3.1.1.</span> <span class="toc-text">configuration配置简介</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用"><span class="toc-number">3.2.</span> <span class="toc-text">使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-migrate迁移"><span class="toc-number">3.2.1.</span> <span class="toc-text">mvn flyway:migrate迁移</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-clean清除所有表"><span class="toc-number">3.2.2.</span> <span class="toc-text">mvn flyway:clean清除所有表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-info打印迁移信息"><span class="toc-number">3.2.3.</span> <span class="toc-text">mvn flyway:info打印迁移信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-validate校验"><span class="toc-number">3.2.4.</span> <span class="toc-text">mvn flyway:validate校验</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-undo撤销"><span class="toc-number">3.2.5.</span> <span class="toc-text">mvn flyway:undo撤销</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-baseline基准"><span class="toc-number">3.2.6.</span> <span class="toc-text">mvn flyway:baseline基准</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mvn-flyway-repair修复"><span class="toc-number">3.2.7.</span> <span class="toc-text">mvn flyway:repair修复</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://fengzxia.gitee.io/posts/cd84d80b.html" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://fengzxia.gitee.io/posts/cd84d80b.html&text=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://fengzxia.gitee.io/posts/cd84d80b.html&is_video=false&description=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=flyway入门使用教程&body=Check out this article: https://fengzxia.gitee.io/posts/cd84d80b.html"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://fengzxia.gitee.io/posts/cd84d80b.html&title=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://fengzxia.gitee.io/posts/cd84d80b.html&name=flyway入门使用教程&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://fengzxia.gitee.io/posts/cd84d80b.html&t=flyway入门使用教程" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy;
    
    
    2019-2020
    只是学习学习
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->

<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">


<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">


    <!-- jquery -->

<script src="/lib/jquery/jquery.min.js"></script>


<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>

<!-- clipboard -->

  
<script src="/lib/clipboard/clipboard.min.js"></script>

  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功!");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

    <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?54382acbd8c4bc66535bce135e0ac166";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>

<!-- Disqus Comments -->


</body>
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https'){
   bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
  }
  else{
  bp.src = 'http://push.zhanzhang.baidu.com/push.js';
  }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
</html>
